/*
 * Copyright (c) 2005, 2014 vacoor
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.vacoor.nothing.security.controller;

import com.google.common.collect.Maps;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.vacoor.nothing.web.domain.Filters;

import java.io.IOException;
import java.util.Map;

/**
 * @author vacoor
 */
@Controller
@RequestMapping("/merchant")
public class MapController {

    @RequestMapping
    public String index() {
        return "map";
    }

    /**
     * 查询给定区域内的地图标注
     *
     * ne 东北(地图右上角)
     * sw 西南(地图左下角)
     * >= sw.lng && <= ne.lng && >= sw.lat && <= ne.lat
     */
    @ResponseBody
    @RequestMapping("map-points")
    public Map<String, Object> getMapPoints(
            @RequestParam("sw.lng") Double swLng,
            @RequestParam("sw.lat") Double swLat,
            @RequestParam("ne.lng") Double neLng,
            @RequestParam("ne.lat") Double neLat,
            String type
    ) throws IOException {
        Filters filters = Filters.create().ge("longitude", swLng).le("longitude", neLng).ge("latitude", swLat).le("latitude", neLat);
//        List<Merchant> merchants = merchantService.findMany(type, filters);
        Map<String, Object> ret = Maps.newHashMap();
//        ret.put("points", merchants);
        return ret;
    }
}
